﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using ManageStore.IViews;

namespace ManageStore.Forms
{
    public class BaseForm : Form
    {
        #region IBaseView Members
        // New.
        public event MethodInvoke EvtNew;
        // Edit.
        public event MethodInvoke EvtEdit;
        // Delete.
        public event MethodInvoke EvtDelete;
        // Save.
        public event MethodInvoke EvtSave;
        // Close.
        public event MethodInvoke EvtClose;

        // New.
        public void OnEvtNew(params object[] pParams)
        {
            if (EvtNew != null)
                EvtNew(pParams);
        }
        // Edit.
        public void OnEvtEdit(params object[] pParams)
        {
            if (EvtEdit != null)
                EvtEdit(pParams);
        }
        // Delete.
        public void OnEvtDelete(params object[] pParams)
        {
            if (EvtDelete != null)
                EvtDelete(pParams);
        }
        // Save.
        public void OnEvtSave(params object[] pParams)
        {
            if (EvtSave != null)
                EvtSave(pParams);
        }
        // Close.
        public void OnEvtClose(params object[] pParams)
        {
            if (EvtClose != null)
                EvtClose(pParams);
        }

        // Before.
        public virtual bool BeforeHandler(string pEventName, params object[] pParams)
        {
            return true;
        }
        // Error.
        public virtual bool ErrorHandler(string pEventName, params object[] pParams)
        {
            return true;
        }
        // Completed.
        public virtual bool CompletedHandler(string pEventName, params object[] pParams)
        {
            return true;
        }
        // Validation.
        public virtual bool ValidationHandler(string pEventName, params object[] pParams)
        {
            return true;
        }

        #endregion
    }
}
